<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 创建一个时间对象 */
        var d = new Date();//获取到的就是当前时间
        //获取年
        console.log(d.getFullYear());
        //获取月=> 0~11之间     0表示的是1月份....11表示的12月份
        console.log(d.getMonth()+1);
        //获取日
        console.log(d.getDate());
        //获取时
        console.log(d.getHours());
        //获取分
        console.log(d.getMinutes());
        //获取秒
        console.log(d.getSeconds());
        //获取周几
        console.log(d.getDay());
    </script>
</body>
</html>